#define  _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int n = 0;
	scanf("%d", &n);
	int arr[100][100] = { 0 };
	int count = 1;
	int di = 1;
	int i = 1;
	int j = 1;
	int x = n * n;
	while (count <= x)
	{

		int flag = 1;
		if (di == 1)
		{
			while (arr[i][j] == 0)
			{
				arr[i][j] = count;
				count++;
				j++;
				flag = 0;
				if (count-1 == n)
					break;
			
				
			}
		}
		else if (di == 2)
		{
			while (arr[i][j] == 0)
			{
				arr[i][j] = count;
				count++;
				i++;
				flag = 0;
				if (count-1 == 2*n-1)
					break;
				

			}
		}
		else if (di == 3)
		{
			while (arr[i][j] == 0)
			{
				arr[i][j] = count;
				count++;
				j--;
				flag = 0;
				if (count-1 == 3 * n - 2)
					break;
				

			}
		}
		else
		{
			while (arr[i][j] == 0)
			{
				arr[i][j] = count;
				count++;
				i--;
				flag = 0;

			}
		}
		if (di < 4)
		{
			if (di == 1)
				j--;
			if (di == 2)
				i--;
			if (di == 3)
				j++;
			di++;

		}
		else
		{
			di = 1;
			i++;
		}
		if (count <= x)
		{
			count--;
			arr[i][j] = 0;
		}
	}

	for (i = 1; i <= n; i++)
	{
		for (j = 1; j <= n; j++)
		{
			printf("%d ", arr[i][j]);
		}
		printf("\n");
	}
}